<template>
  <div>
    <div class="recommend-title">热门推荐</div>
    <ul>
      <li class="item border-bottom" v-for="item of recommendList" :key="item.id">
      <!-- 添加一像素边框的类border-bottom -->
        <img class="item-img" :src="item.imgUrl"/>
        <div class="item-info">
          <p class="item-title">{{item.title}}</p>
          <p class="item-desc">{{item.desc}}</p>
          <button class="item-btn">查看详情</button>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'HomeRecommend',
  props: {
    recommendList: Array
  }
}
</script>

<style lang="stylus" scoped>
  @import '~styles/mixins.styl'
  .recommend-title
    margin-top: .1rem
    line-height: .8rem
    // 只使用line-height即可使文字居中，因为使用之后会获得半行间距，加在content-box的上下两侧，得到line-box的高度
    text-indent: .2rem
    background: #eee
  .item
    overflow: hidden
    display: flex
    height: 1.9rem
    .item-img
      height: 1.7rem
      width: 1.7rem
      padding: .1rem
    .item-info
      flex: 1
      padding: .1rem
      min-width: 0
      // 为啥设置后ellipsis()就可以就可以正常的起作用，疑惑
      .item-title
        line-height: .54rem
        font-size: .32rem
        font-weight: bold
        ellipsis()
      .item-desc
        line-height: .4rem
        color: #ccc
        ellipsis()
      .item-btn
        line-height: .44rem
        margin-top: .16rem
        padding: 0 .2rem
        background: #ff9300
        color: #fff
        border-radius: .1rem
</style>
